package com.ch.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ch.model.bo.ReportBO;
import com.ch.model.entity.Report;
import com.ch.model.query.ReportQuery;
import com.ch.service.ReportService;
import com.ch.mapper.ReportMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Lenovo
 * @description 针对表【report】的数据库操作Service实现
 * @createDate 2024-06-14 09:43:05
 */
@Service
@RequiredArgsConstructor
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report>
		implements ReportService {
	private final ReportMapper reportMapper;

	@Override
	public IPage<ReportBO> getPage(ReportQuery reportQuery) {
		int pageNum = reportQuery.getPageNum();
		int pageSize = reportQuery.getPageSize();
		Page<ReportBO> page = new Page<>(pageNum, pageSize);
		Page<ReportBO> RPage = this.baseMapper.getRPage(page, reportQuery);
		return RPage;
	}

	@Override
	public List<ReportBO> getReport(String date) {
		return this.baseMapper.getReport(date);
	}

	@Override
	public Integer deleteR(Integer reportId) {
		return reportMapper.deleteByReportId(reportId);
	}

	@Override
	public boolean updateR(Integer reportId,String diagnose) {
		return reportMapper.updateR(reportId,diagnose);
	}

	@Override
	public boolean updateState(int id) {
		return this.update(new LambdaUpdateWrapper<Report>()
				.eq(Report::getReportid, id)
				.set(Report::getState, 3)
		);
	}
}




